<template>
  <div class="home">
    用户名：<input type="text" v-model="username" /> 密码：
    <input type="text" v-model="password" />
    <button @click="login">登陆</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    login() {
      this.$http
        .post("/login", {
          username: this.username,
          password: this.password,
        })
        .then((res) => {
          console.log(res);
          if (res.data.meta.status == 200) {
            this.$router.push("/about");
            localStorage.setItem("token", res.data.data.token);
          }
        });
    },
  },
};
</script>
